using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
namespace CXDB
{
    /// <summary>
    /// Controller class for CX_Provider
    /// </summary>
    [System.ComponentModel.DataObject]
    public partial class CxProviderController
    {
        // Preload our schema..
        CxProvider thisSchemaLoad = new CxProvider();
        private string userName = String.Empty;
        protected string UserName
        {
            get
            {
				if (userName.Length == 0) 
				{
    				if (System.Web.HttpContext.Current != null)
    				{
						userName=System.Web.HttpContext.Current.User.Identity.Name;
					}
					else
					{
						userName=System.Threading.Thread.CurrentPrincipal.Identity.Name;
					}
				}
				return userName;
            }
        }
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public CxProviderCollection FetchAll()
        {
            CxProviderCollection coll = new CxProviderCollection();
            Query qry = new Query(CxProvider.Schema);
            coll.LoadAndCloseReader(qry.ExecuteReader());
            return coll;
        }
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public CxProviderCollection FetchByID(object Id)
        {
            CxProviderCollection coll = new CxProviderCollection().Where("ID", Id).Load();
            return coll;
        }
		
		[DataObjectMethod(DataObjectMethodType.Select, false)]
        public CxProviderCollection FetchByQuery(Query qry)
        {
            CxProviderCollection coll = new CxProviderCollection();
            coll.LoadAndCloseReader(qry.ExecuteReader()); 
            return coll;
        }
        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public bool Delete(object Id)
        {
            return (CxProvider.Delete(Id) == 1);
        }
        [DataObjectMethod(DataObjectMethodType.Delete, false)]
        public bool Destroy(object Id)
        {
            return (CxProvider.Destroy(Id) == 1);
        }
        
        
    	
	    /// <summary>
	    /// Inserts a record, can be used with the Object Data Source
	    /// </summary>
        [DataObjectMethod(DataObjectMethodType.Insert, true)]
	    public void Insert(string ProviderName,string DeviceName,DateTime? ShamTime,string ShamProject,string ShamDetail,DateTime? XinghuTime,string XinghuProject,string XinghuDetail,DateTime? ContractTime,string ContractProject,string ContractDetail,string OtherDetail,int? EnteringUserid,int? EnteringDeptID,int? DeptMasterId,DateTime? DeptMasterTime,int? DeptMasterStatus,string DeptMasterRemark,int? TechMasterId,DateTime? TechMasterTime,int? TechMasterStatus,string TechMasterRemark,int? OfficeMasterId,DateTime? OfficeMasterTime,int? OfficeMasterStatus,string OfficeMasterRemark,int? BossId,DateTime? BossTime,int? BossStatus,string BossRemark,DateTime? InTime,Guid? Guid)
	    {
		    CxProvider item = new CxProvider();
		    
            item.ProviderName = ProviderName;
            
            item.DeviceName = DeviceName;
            
            item.ShamTime = ShamTime;
            
            item.ShamProject = ShamProject;
            
            item.ShamDetail = ShamDetail;
            
            item.XinghuTime = XinghuTime;
            
            item.XinghuProject = XinghuProject;
            
            item.XinghuDetail = XinghuDetail;
            
            item.ContractTime = ContractTime;
            
            item.ContractProject = ContractProject;
            
            item.ContractDetail = ContractDetail;
            
            item.OtherDetail = OtherDetail;
            
            item.EnteringUserid = EnteringUserid;
            
            item.EnteringDeptID = EnteringDeptID;
            
            item.DeptMasterId = DeptMasterId;
            
            item.DeptMasterTime = DeptMasterTime;
            
            item.DeptMasterStatus = DeptMasterStatus;
            
            item.DeptMasterRemark = DeptMasterRemark;
            
            item.TechMasterId = TechMasterId;
            
            item.TechMasterTime = TechMasterTime;
            
            item.TechMasterStatus = TechMasterStatus;
            
            item.TechMasterRemark = TechMasterRemark;
            
            item.OfficeMasterId = OfficeMasterId;
            
            item.OfficeMasterTime = OfficeMasterTime;
            
            item.OfficeMasterStatus = OfficeMasterStatus;
            
            item.OfficeMasterRemark = OfficeMasterRemark;
            
            item.BossId = BossId;
            
            item.BossTime = BossTime;
            
            item.BossStatus = BossStatus;
            
            item.BossRemark = BossRemark;
            
            item.InTime = InTime;
            
            item.Guid = Guid;
            
	    
		    item.Save(UserName);
	    }
    	
	    /// <summary>
	    /// Updates a record, can be used with the Object Data Source
	    /// </summary>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
	    public void Update(int Id,string ProviderName,string DeviceName,DateTime? ShamTime,string ShamProject,string ShamDetail,DateTime? XinghuTime,string XinghuProject,string XinghuDetail,DateTime? ContractTime,string ContractProject,string ContractDetail,string OtherDetail,int? EnteringUserid,int? EnteringDeptID,int? DeptMasterId,DateTime? DeptMasterTime,int? DeptMasterStatus,string DeptMasterRemark,int? TechMasterId,DateTime? TechMasterTime,int? TechMasterStatus,string TechMasterRemark,int? OfficeMasterId,DateTime? OfficeMasterTime,int? OfficeMasterStatus,string OfficeMasterRemark,int? BossId,DateTime? BossTime,int? BossStatus,string BossRemark,DateTime? InTime,Guid? Guid)
	    {
		    CxProvider item = new CxProvider();
	        item.MarkOld();
	        item.IsLoaded = true;
		    
			item.Id = Id;
				
			item.ProviderName = ProviderName;
				
			item.DeviceName = DeviceName;
				
			item.ShamTime = ShamTime;
				
			item.ShamProject = ShamProject;
				
			item.ShamDetail = ShamDetail;
				
			item.XinghuTime = XinghuTime;
				
			item.XinghuProject = XinghuProject;
				
			item.XinghuDetail = XinghuDetail;
				
			item.ContractTime = ContractTime;
				
			item.ContractProject = ContractProject;
				
			item.ContractDetail = ContractDetail;
				
			item.OtherDetail = OtherDetail;
				
			item.EnteringUserid = EnteringUserid;
				
			item.EnteringDeptID = EnteringDeptID;
				
			item.DeptMasterId = DeptMasterId;
				
			item.DeptMasterTime = DeptMasterTime;
				
			item.DeptMasterStatus = DeptMasterStatus;
				
			item.DeptMasterRemark = DeptMasterRemark;
				
			item.TechMasterId = TechMasterId;
				
			item.TechMasterTime = TechMasterTime;
				
			item.TechMasterStatus = TechMasterStatus;
				
			item.TechMasterRemark = TechMasterRemark;
				
			item.OfficeMasterId = OfficeMasterId;
				
			item.OfficeMasterTime = OfficeMasterTime;
				
			item.OfficeMasterStatus = OfficeMasterStatus;
				
			item.OfficeMasterRemark = OfficeMasterRemark;
				
			item.BossId = BossId;
				
			item.BossTime = BossTime;
				
			item.BossStatus = BossStatus;
				
			item.BossRemark = BossRemark;
				
			item.InTime = InTime;
				
			item.Guid = Guid;
				
	        item.Save(UserName);
	    }
    }
}
